package nl.vu.few.ibivu.biomodels.shared;

import java.io.Serializable;

import com.google.gwt.core.client.JavaScriptObject;

import nl.vu.few.ibivu.biomodels.client.ui.cytoscapeweb.CytoscapeWebNetworkModelNode;

public class PetrifierNode implements Serializable {
	private static final long serialVersionUID = 961689180374570572L;
	private String id;
	private String label;
	private String uniprotId;
	private PetrifierNodeType type;
	
	private PetrifierNode() {}
	
	public PetrifierNode(String id, String label, PetrifierNodeType type, String uniprotId) {
		this();
		this.id = id;
		this.label = label;
		this.type = type;
		this.uniprotId = uniprotId;
	}
	
	public PetrifierNode(CytoscapeWebNetworkModelNode node) {
		this();
		id = node.getId();
		label = node.getLabel();
		uniprotId = node.getDataFieldAsString(PetrifierDataFieldName.UNIPROT_ID.name());
		type = PetrifierNodeType.valueOf(node.getDataFieldAsString(PetrifierDataFieldName.NODE_ELEMENT_TYPE.name()));
	}
	
	public String getId() {
		return id;
	}
	public String getLabel() {
		return label;
	}
	public String getUniprotId() {
		return uniprotId;
	}
	public PetrifierNodeType getType() {
		return type;
	}
	
	public CytoscapeWebNetworkModelNode cytoscapeWebNetworkModelNode() {
		CytoscapeWebNetworkModelNode obj = (CytoscapeWebNetworkModelNode) JavaScriptObject.createObject();
		obj.setId(id);
		obj.setLabel(label);
		obj.setDataField(PetrifierDataFieldName.NODE_ELEMENT_TYPE.name(), type.name());
		obj.setDataField(PetrifierDataFieldName.UNIPROT_ID.name(), uniprotId);
		return obj;
	}
}
